<?php

namespace api\controllers;

use api\common\controllers\BaseController;
use api\models\Cate;
use Faker\Provider\Uuid;

class CateController extends  BaseController{

    public function actionAddCate(){
        $date = \Yii::$app->request->post();
        $model = new Cate();
        $model->setScenario('add_cate');
        static::$FIELDS_KEY = 'add_cate';
        $model->load($date,'');
        if($model->validate()){
            $model->cate_id = Uuid::uuid();
            if(!$model->insert(false)){
                static::$CODE = 1005;
                static::$STATUSTEXT = '添加失败';
            }
        }
        return $model;
    }

    protected function verbs()
    {
        $verbs = parent::verbs(); // TODO: Change the autogenerated stub
        $verbs['add_cate'] = ['POST'];
        return $verbs;
    }
}
